package com.edmond.jyframe.adapter;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import com.edmond.jyframe.R;
import com.edmond.jyframe.classes.MineTool;
import com.edmond.jyframe.views.GridLayoutItemDecoration;

import java.util.List;

/**
 * Created by edmond on 17-3-25.
 */

public class MineAdapter extends BaseHeaderFooterAdapter<String> {
    private List<MineTool> mineTools;

    public MineAdapter(Context context, List data,List<MineTool> mineTools) {
        super(context, data);
        this.mineTools = mineTools;
    }

    @Override
    public  MineHeader initHeader(ViewGroup parent) {
        return new MineHeader(getInflater().inflate(R.layout.header_mine, parent, false));
    }

    @Override
    public void bindHeader(BaseItem item) {
        ((MineHeader)item).recyclerView.setLayoutManager(new GridLayoutManager(getContext(),3));
        ((MineHeader)item).recyclerView.setNestedScrollingEnabled(false);
        ((MineHeader)item).recyclerView.setAdapter(new MineToolsAdapter(getContext(),mineTools));
        ((MineHeader)item).recyclerView.addItemDecoration(new GridLayoutItemDecoration(getContext()));
    }

    @Override
    public Footer initFooter(ViewGroup parent) {
        return new MineFooter(getInflater().inflate(R.layout.footer_mine,parent,false));
    }

    @Override
    public void bindFooter(BaseItem item) {

    }

    @Override
    public BaseItem initItem(ViewGroup parent) {
        return new MineItem(getInflater().inflate(R.layout.item_goods,parent,false));
    }

    @Override
    public void bindItem(BaseItem item, int position) {

    }

    class MineHeader extends Header{
        private RecyclerView recyclerView;
        public MineHeader(View itemView) {
            super(itemView);
        }

        @Override
        public void initViews(View view) {
            recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
        }
    }

    class MineFooter extends Footer{

        public MineFooter(View itemView) {
            super(itemView);
        }

        @Override
        public void initViews(View view) {

        }
    }

    class MineItem extends Item{

        public MineItem(View itemView) {
            super(itemView);
        }

        @Override
        public void initViews(View view) {

        }
    }
}
